package com.nbsaas.boot.project.rest.resource;

import com.nbsaas.boot.jpa.data.core.BaseResource;
import com.nbsaas.boot.project.api.apis.ProjectCatalogApi;
import com.nbsaas.boot.project.api.domain.request.ProjectCatalogRequest;
import com.nbsaas.boot.project.api.domain.response.ProjectCatalogResponse;
import com.nbsaas.boot.project.api.domain.simple.ProjectCatalogSimple;
import com.nbsaas.boot.project.data.entity.ProjectCatalog;
import com.nbsaas.boot.project.data.repository.ProjectCatalogRepository;
import com.nbsaas.boot.project.rest.convert.ProjectCatalogEntityConvert;
import com.nbsaas.boot.project.rest.convert.ProjectCatalogResponseConvert;
import com.nbsaas.boot.project.rest.convert.ProjectCatalogSimpleConvert;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.function.Function;

/**
 * 项目分类-业务接口实现
 */
@Transactional
@Service
public class ProjectCatalogResource extends BaseResource<ProjectCatalog, ProjectCatalogResponse, ProjectCatalogSimple, ProjectCatalogRequest> implements ProjectCatalogApi {

    @Resource
    private ProjectCatalogRepository projectCatalogRepository;

    @Override
    public JpaRepositoryImplementation<ProjectCatalog, Serializable> getJpaRepository() {
        return projectCatalogRepository;
    }

    @Override
    public Function<ProjectCatalog, ProjectCatalogSimple> getConvertSimple() {
        return new ProjectCatalogSimpleConvert();
    }

    @Override
    public Function<ProjectCatalogRequest, ProjectCatalog> getConvertForm() {
        return new ProjectCatalogEntityConvert();
    }

    @Override
    public Function<ProjectCatalog, ProjectCatalogResponse> getConvertResponse() {
        return new ProjectCatalogResponseConvert();
    }


}


